import os
import time
import random


class SaveFile:
    @staticmethod
    def save_xls(file):
        if file.filename.lower().endswith('.xls'):
            suffix = '.xls'
        elif file.filename.lower().endswith('.xlsx'):
            suffix = '.xlsx'
        else:
            return 'error'
        filename = time.strftime('%Y%m%d') + str(random.randint(0, 999999)) + suffix
        print('filename: ', filename)
        file.save(os.path.join(os.getcwd(), 'files', filename))
        return filename
